package com.lk.common.utils.excel.thread;

import java.util.concurrent.ArrayBlockingQueue;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.multipart.MultipartFile;

import com.lk.common.utils.excel.entity.Flag;
import com.lk.common.utils.excel.util.ExcelUtil;

public class ReadThread<T> implements Runnable {
	
	private static final Logger logger = LoggerFactory.getLogger(ReadThread.class);
	
	private int sheetIndex;
	private int startRow;
	private MultipartFile file;
	private ArrayBlockingQueue<T> queue;
	private volatile Flag flag;
	private Class clazz;

	public ReadThread(int sheetIndex, int startRow, MultipartFile file, ArrayBlockingQueue<T> queue,Class clazz,Flag flag) {
		this.sheetIndex = sheetIndex;
		this.startRow = startRow;
		this.file = file;
		this.queue = queue;
		this.clazz = clazz;
		this.flag = flag;
	}

	@Override
	public void run() {
		try {
			new ExcelUtil<T>(clazz).importExcelByThread(sheetIndex, startRow, file, queue,flag);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
